home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5027 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: oasis.novia.net!not-for-mail
  2. From: nicatt@oasis.novia.net (Nicatt)
  3. Newsgroups: comp.lang.c
  4. Subject: atof/atoi
  5. Date: 10 Feb 1996 16:40:25 GMT
  6. Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
  7. Message-ID: <4fihpp$j5q@nntp.novia.net>
  8. NNTP-Posting-Host: oasis.novia.net
  9. X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]
  10.  
  11.  
  12. I am a rookie.
  13.  
  14. I have been through the faq and three C books and cannot find *how*
  15. to use atof/atoi.  Each mentions them and their purpose, but none explains 
  16. how to use them.
  17.  
  18. I wrote a program that works fine.  However, one of the requirements
  19. is to trap for alpha characters.  If I use "gets", my Y/N response
  20. prior to the loop below falls through.  I can define *catch* as a char
  21. and trap the character after scanf (ex:  catch=getchar();  ) but I have
  22. not figured how to use that to my advantage to break the loop, reask for
  23. the correct value to be entered, and restart the loop at that point.  
  24.  
  25. This is an internet class and the instructor said to use atof.  
  26.  
  27. The question is, how do you use atof?
  28.  
  29. for(count=0; count<STUDENTS; count++)
  30.   { printf("\nWhat is student %i's grade average ", (count+1));
  31.     for(count2=0; count2<GRADES; count2++)
  32.       { printf("in class number %i?\n ", (count2+1));
  33.         scanf(" %f", &number);
  34.         grades[count][count2]=number;
  35.         printf("You entered %.3f \n\n", grades[count][count2]);
  36.   }   }
  37.  
  38. Thank you in advance for any assistance you may render.
  39.  
  40. Bob
  41. nicatt@oasis.novia.net
  42.  
  43.